package com.example.human_resource_management.mapper;

import com.example.human_resource_management.entry.dto.AttendanceEmployeeDto;
import com.example.human_resource_management.entry.po.Attendance;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

/**
* @author Lenovo
* @description 针对表【attendance(考勤记录表)】的数据库操作Mapper
* @createDate 2025-06-09 11:48:49
* @Entity com.example.human_resource_management.entry.po.Attendance
*/
public interface AttendanceMapper extends BaseMapper<Attendance> {



    //管理员端
    @Select("SELECT a.record_id, e.name AS employee_name, a.attend_date, a.status, a.punch_time " +
            "FROM attendance a " +
            "JOIN employee e ON a.emp_id = e.emp_id")
    List<AttendanceEmployeeDto> selectAttendanceEmployeeList();

    @Select("SELECT a.record_id, e.name AS employee_name, a.attend_date, a.status, a.punch_time " +
            "FROM attendance a " +
            "JOIN employee e ON a.emp_id = e.emp_id " +
            "WHERE a.record_id = #{recordId}")
    AttendanceEmployeeDto selectAttendanceEmployeeById(Long recordId);

    @Select("SELECT a.record_id, e.name AS employee_name, a.attend_date, a.status, a.punch_time " +
            "FROM attendance a " +
            "JOIN employee e ON a.emp_id = e.emp_id " +
            "WHERE a.attend_date = #{date}")
    List<AttendanceEmployeeDto> selectAttendanceByDate(LocalDate date);

}




